package topic3;

import java.util.ArrayList;
import java.util.List;

public class lengthOfLongestSubstring {
    public static void main(String[] args) {
        String s  = "abcabcbb";
        int i = lengthOfLongestSubstring(s);
        System.out.println(i);
    }

    public static int lengthOfLongestSubstring(String s) {
        int maxLength = 0;
        for (int i = 0; i < s.length(); i++) {
            List<Character> characters = new ArrayList<>();
            for (int j = i; j < s.length(); j++) {
                if (characters.contains(s.charAt(j))) {
                    break;
                }
                characters.add(s.charAt(j));
                maxLength = Math.max(characters.size(), maxLength);
            }
        }
        return maxLength;
    }


}
